
"""添加公告页面基类"""
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class NewNoticePage(BasePage):
    url = '/crm/index.php?m=announcement'
    #定位器
    #公告标题
    notice_name_locator=(By.CLASS_NAME,'span4')
    #切换iframe
    iframe_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(7) > td:nth-child(2) > div > div.ke-edit > iframe')
    #公告内容
    notice_neirong_locator=(By.XPATH,'/html/body')
    #保存
    save_notice_locator=(By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td/input[1]')


    #输入公告标题
    def input_notice_title(self,notice_name):
        self.driver.find_element(*self.notice_name_locator).send_keys(notice_name)

    #切换iframe
    def switch_to_content_iframe(self):
        iframe = self.driver.find_element(*self.iframe_locator)
        self.driver.switch_to.frame(iframe)
    #输入公告内容
    def input_notice_content(self,notice_content):
        self.driver.find_element(*self.notice_neirong_locator).send_keys(notice_content)

    #点击保存
    def click_notice_save(self):
        self.driver.find_element(*self.save_notice_locator).click()
